<!-- Copyright (c) 2019-2020 十三 all rights reserved. -->
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="mall/header::head-fragment('NewBee商城-商品详情','detail')">
</head>
<body>
<header th:replace="mall/header::header-fragment"></header>

<p id="detail">
    <!-- nav -->
    <nav th:replace="mall/header::nav-fragment"></nav>

    <div class="intro mt20 w clearfix">
        <div class="left fl" style="position: relative;">
            <div class="swiper-container fl">
<!--                <img src="'/mall/image/imagess/'+${filmDetail.filmPhoto}" width="175" height="233">-->
                <img th:src="@{'/mall/image/imagess/'+${filmDetail.filmPhoto}}"  width="175" height="233">
<!--                <img src="'./mall/image/imagess/'+${filmDetail.filmPhoto}" width="175" height="233">-->
           </div>
        </div>
        <div class="right fl">
            <div class="h3 ml20 mt20"><p class="name" th:text="${filmDetail.filmName}">NewBeeMall</p></div>
            <div class="sub_title mr40 ml20 mt10" ><p class="name" th:text="${filmDetail.filmDirect}">NewBeeMall</p></div>
            <div class="tb-extra ml20" id="J_tbExtra">
                <dl>
                    <dt>类型:</dt>
                    <dd th:text="${filmDetail.filmType}">悬疑 惊悚 剧情</dd>
                </dl>
                <dl>
                    <dt>时长:</dt>
                    <dd th:text="${filmDetail.fileZone}">美国/98分钟</dd>
                    <dd th:text="${filmDetail.fileTime}">美国/98分钟</dd>
                </dl>
                <dl>
                    <dt>上映日期:</dt>
                    <dd th:text="${time}">2021年5月28日中国大陆上映</dd>
                </dl>
            </div>


<!--            <div class="order">-->
<!--                <input class="car1" type="button" th:onclick="'saveAndGoCart('+${goodsDetail.goodsId}+')'" value="我要评价"/>-->
<!--                <input class="car2" type="button" th:onclick="'saveToCart('+${goodsDetail.goodsId}+')'" value="特惠购票"/>-->
<!--            </div>-->

<!--            <div class="item_price mr40 ml20 mt10">-->

<!--                    <th:block th:text="${goodsDetail.sellingPrice}+'分'"></th:block>-->
<!--                <del>-->
<!--                    <th:block th:text="${goodsDetail.originalPrice}+'亿'"></th:block>-->
<!--                </del>-->
<!--            </div>-->
        </div>

        <div class="right fr">
            <div weight="100px" height="100px" th:href="@{'/film?goodsCategoryId='+${filmDetail.filmId}}">想看</div>
            <input class="car1" type="button" th:onclick="'saveAndGoCart('+${filmDetail.filmId}+')'" value="我要评价"/>
            <input class="car2" type="button" th:onclick="'selectFilm('+${filmDetail.filmId}+')'" value="购买"/>
        </div>
        <div class="clear"></div>


    </div>
    <!-- 这里使用的是 th:utext 标签，用 th:text 不会解析 html，用 th:utext 会解析 html -->
    <div class="goods mt20 w clearfix" th:utext="电影简介"></div>
    <p th:text="${filmDetail.filePlot}">

    </p>
</div>

<!--<div th:replace="mall/footer::footer-fragment"></div>-->

<!-- jQuery -->
<script th:src="@{/admin/plugins/jquery/jquery.min.js}"></script>
<script th:src="@{/admin/plugins/sweetalert/sweetalert.min.js}"></script>
<script th:src="@{/mall/js/search.js}" type="text/javascript"></script>
<script type="text/javascript">
    //查询该电影
    function selectFilm(id) {
        window.location.href = "/film/selectFilm/" + id;
    }

    /**
     * 添加到购物车
     */
    function saveToCart(id) {
        var goodsCount = 1;
        var data = {
            "goodsId": id,
            "goodsCount": goodsCount
        };
        $.ajax({
            type: 'POST',
            url: '/shop-cart',
            contentType: 'application/json',
            data: JSON.stringify(data),
            success: function (result) {
                if (result.resultCode == 200) {
                    swal({
                        title: "添加成功",
                        text: "确认框",
                        icon: "success",
                        buttons: true,
                        dangerMode: true,
                    }).then((flag) => {
                            window.location.reload();
                        }
                    );
                } else {
                    swal(result.message, {
                        icon: "error",
                    });
                }
            },
            error: function () {
                swal("操作失败", {
                    icon: "error",
                });
            }
        });
    }

    /**
     * 添加到购物车并跳转至购物车页面
     */
    function saveAndGoCart(id) {
        var goodsCount = 1;
        var data = {
            "goodsId": id,
            "goodsCount": goodsCount
        };
        $.ajax({
            type: 'POST',
            url: '/shop-cart',
            contentType: 'application/json',
            data: JSON.stringify(data),
            success: function (result) {
                if (result.resultCode == 200) {
                    swal({
                        title: "已将商品加入购物车",
                        icon: "success",
                        buttons: {
                            cancel: "留在当前页",
                            confirm: "去购物车结算"
                        },
                        dangerMode: false,
                    }).then((flag) => {
                            if (flag) {
                                window.location.href = '/shop-cart';
                            }
                        }
                    );
                } else {
                    swal(result.message, {
                        icon: "error",
                    });
                }
            },
            error: function () {
                swal("操作失败", {
                    icon: "error",
                });
            }
        });
    }
</script>
</body>
</html>
